home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 15 / BBS in a box XV-1.iso / Files / Util / M / MacShell 0.53b.sit / MacShell 0.53b / MacShell 0.53b.rsrc / help_16630_set < prev    next >
Encoding:
Text File  |  1995-03-07  |  2.3 KB  |  71 lines

  1. NAME
  2.    set - set a shell variable, or report values of set variables
  3.  
  4. SYNTAX
  5.    set
  6.       set varname1 [varname2...]
  7.    set varname1 = value [varname2...]
  8.    set varname = (value1 value2...) [varname2...]
  9.  
  10. DESCRIPTION
  11.  
  12. Set has two general forms: without arguments and with arguments. Without arguments, set simply causes a list of all currently defined shell variables to be reported to its standard output.  With arguments, set defines or redefines a shell variable and its value.
  13.  
  14. A shell variable may take a value of zero or more words.  If the value consists of more than one word, the individual words may be selected by means of an index value in square brackets immediately following the variable name.  Index values begin at 1.  Supplying an index value of zero is an error.
  15.  
  16. The following are the forms of "set" involving variable name arguments, descriptions of what they do.  Although it isn't shown here, many variables or variable-value pairs may appear on a single command line.
  17.  
  18.   set varname
  19. Create the variable named "varname." Its value will be a single null word.
  20.  
  21.   set varname = value
  22. Create the variable "varname."  Its value will be the word "value."
  23.  
  24.   set varname = ()
  25. Create the variable "varname."  It's value will be null (zero words).
  26.  
  27.   set varname = (val1 val2)
  28. Create the variable "varname." It's value will be two words: "val1" and "val2"
  29.  
  30.   set varname[1] = val3
  31. Assuming this invocation succeeded the one above, this would reset the first word of varname from "val1" to "val3."  Note that it is an error to use an indexed variable with set that exceeds the number of words already defined for a the variable in question. 
  32.  
  33. SHELL VARIABLE EXAMPLES
  34.  
  35. Suppose the following shell variables were set as shown:
  36.  
  37.    set a=1
  38.    set b=abc
  39.    set c
  40.       set d=()
  41.    set e=(1 2 3)
  42.       set e[1]=4
  43.  
  44. Here are some simple examples using the shell utility "echo" to report the results of variable substitution with the variables defined above: (See the main manual entry for "macshell" for information about the variable substitution mechanism.)
  45.  
  46.    echo $a
  47.     1
  48.    echo $e
  49.     (4 2 3)
  50.    echo $e[2]
  51.     2
  52.    echo $e[$a]
  53.     4
  54.    echo I'm${e[$a]}it
  55.     I'm4it
  56.    echo $#e
  57.     3
  58.    echo $?b
  59.     1
  60.    echo he's $?{b}for fun
  61.      he's 1for fun
  62.    echo $?z
  63.     0
  64.  
  65. SEE ALSO
  66.    unset, echo, macshell
  67.  
  68.  
  69.  
  70.